package com.example.admin.pullrefresh;

import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.ListView;


public class MainActivity extends AppCompatActivity implements PullRefreshLayout.OnRefresh {

    private PullRefreshLayout prl;

    private Handler handler = new Handler() {


    };

    private ListView listView;
    private ArrayAdapter <String> adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        prl = (PullRefreshLayout) findViewById(R.id.pullrefreshlayout);
        prl.setRefresh(this);
        listView = (ListView) findViewById(R.id.listview);
        adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,new String[]{"A","B","C","D","E","F","G","A","A","A","A","A","A","A","A","A","A"});
        listView.setAdapter(adapter);
    }


    @Override
    public void refresh() {
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                prl.refreshOver();
            }
        }, 3000);
    }
}
